package com.hellogood.yaohuo.server.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.hellogood.yaohuo.server.db.DBHelper;
import com.hellogood.yaohuo.shared.entity.PsDetail;

public class PsDetailDAO extends DBHelper {
	Logger log = Logger.getLogger(this.getClass());
	@Override
	public List<?> initializeObject(ResultSet rs) throws SQLException {
		List<PsDetail> psDetailList = new ArrayList<PsDetail>();
		if (rs != null) {
			while (rs.next()) {
				PsDetail psDetail = new PsDetail();
				psDetail.setPsBillNo(rs.getString("psBillNo"));
				psDetail.setPluCode(rs.getString("pluCode"));
				psDetail.setBarCode(rs.getString("barCode"));
				psDetail.setBra(rs.getString("bra"));
				psDetail.setColor(rs.getString("color"));
				psDetail.setSize(rs.getString("CSize"));
				psDetail.setPluName(rs.getString("pluName"));
				psDetail.setSglCount(rs.getInt("sglCount"));
				psDetail.setjPrice(rs.getBigDecimal("jPrice"));
				psDetail.setPsPrice(rs.getBigDecimal("psPrice"));
				psDetail.setPrice(rs.getBigDecimal("price"));
				psDetail.setCounts(rs.getInt("counts"));
				psDetail.setCost(rs.getBigDecimal("cost"));
				psDetail.setNetCost(rs.getBigDecimal("netCost"));
				psDetail.setTotal(rs.getBigDecimal("total"));
				psDetail.setTimeMark(rs.getString("timeMark"));
				psDetail.setRzDate(rs.getString("rzDate"));
				psDetail.setRemark(rs.getString("remark"));
				psDetailList.add(psDetail);
			}
		}
		return psDetailList;
	}

	@SuppressWarnings("unchecked")
	public List<PsDetail> getDetailByBillNo(String billNo) {
		List<PsDetail> list = new ArrayList<PsDetail>();
		String sql = "SELECT * FROM psDetail WHERE psBillNo = '" + billNo + "'";
		list = (List<PsDetail>) super.query(sql);
		return list;
	}
}
